package exam.bak.tencent;

import java.util.Arrays;
import java.util.Scanner;

public class P2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.nextLine().trim());
        while (N-- > 0) {
            int size = Integer.parseInt(scanner.nextLine().trim());
            int[] nums = Arrays.stream(scanner.nextLine().trim().split("\\s+")).mapToInt(Integer::valueOf).toArray();
            int max = 0;
            for (int i = 0; i < nums.length; i++) {
                max = Integer.max(max, solve(nums, i));
            }
            System.out.println(max);
        }
    }

    public static int solve(int[] nums, int i) {
        int total = nums[i];
        i += nums[i];
        while (0 <= i && i <= nums.length) {
            total += nums[i];
            i += nums[i];
        }
        return total;
    }
}
